package com.xuxin.baby.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xuxin.baby.R;
import com.xuxin.baby.bean.ChildEatingBean;
import com.xuxin.baby.utils.BaseUtils;

import org.jetbrains.annotations.NotNull;

/**
 * Created by xu_xin
 * Created on 2020.08.04 0004
 * 宝宝喂养
 */
public class ChildEatingAdapter extends BaseQuickAdapter<ChildEatingBean.ResultBean.ItemsBean, BaseViewHolder> {

    public ChildEatingAdapter() {
        super(R.layout.item_child_data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, ChildEatingBean.ResultBean.ItemsBean itemsBean) {
        float feedTimes = itemsBean.getFeedTimes();
        float feedBreastAmt = itemsBean.getFeedBreastAmt();
        float feedPowderedAmt = itemsBean.getFeedPowderedAmt();
        String eventContent = itemsBean.getEventContent();
        if (feedTimes != 0) {
            holder.setText(R.id.item_child_data_name, "母乳; " + feedTimes + "分钟");
        } else if (feedBreastAmt != 0) {
            holder.setText(R.id.item_child_data_name, "瓶装母乳; " + feedBreastAmt + "ml");
        } else if (feedPowderedAmt != 0) {
            holder.setText(R.id.item_child_data_name, "奶粉; " + feedPowderedAmt + "ml");
        } else {
            holder.setText(R.id.item_child_data_name, "辅食; " + eventContent);
        }
        holder.setText(R.id.item_child_data_time, BaseUtils.getTime(itemsBean.getEventDate()));
    }
}